<?php

class WebUser extends CWebUser
{
    public function init()
    {
        parent::init();
    }

    public function isLogin()
    {
        $id = $this->getId();
        return (!empty($id));
    }

    public function isAdmin()
    {
        $id = $this->getId();
        $user = User::model()->find('LOWER(name)=?', array($id));
        if ($user) {
            return ($user->rid == Yii::app()->params['admin_rid']);
        } else {
            return false;
        }
    }

    public function getUser()
    {
        $id = $this->getId();
        $user = User::model()->find('LOWER(name)=?', array($id));
        return $user;
    }

}

?>
